package com.xixi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xixi.entity.ProductImage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ProductImageMapper extends BaseMapper<ProductImage> {

    @Select("SELECT * FROM product_images WHERE product_id = #{productId} ORDER BY sort_order")
    List<ProductImage> selectByProductId(@Param("productId") Integer productId);

    @Select("DELETE FROM product_images WHERE product_id = #{productId}")
    void deleteByProductId(@Param("productId") Integer productId);

    @Select("SELECT image_url FROM product_images WHERE product_id = #{productId} ORDER BY sort_order")
    List<String> selectImagesByProductId(@Param("productId") Integer productId);
}